{% extends 'base.html' %}

{%block title%}Yeni Kod{%endblock%}

{%block content %}

    <form action="." method="POST">
		<div>
		    {{ form.title.errors }}
		    <label for="id_title">Baslik:</label>
		    {{ form.title }}
		</div>
		<div>
		    {{ form.description.errors }}
		    <label for="id_description">Tanim:</label>
		    {{ form.description }}
		</div>
		<div>
		    {{ form.code.errors }}
		    <label for="id_code">Kod:</label>
		    {{ form.code }}
		</div>
		<div>
		    {{ form.category.errors }}
		    <label for="id_category">Kategori:</label>
		    {{ form.category }}
		</div>
		<div>
		    {{ form.readable.errors }}
		    <label for="id_readable">Herkes okuyabilsin?:</label>
		    {{ form.readable }}
		</div>
		<div>
		    {{ form.writable.errors }}
		    <label for="id_writable">Herkes degistirebilir?:</label>
		    {{ form.writable }}
		</div>
		<!-- 
        <table>
            {{ form.as_table }}
        </table>
        -->
        <p><input type="submit" value="Ekle"></p>
    </form>

	<h2>Kodlar ( {{codes.count}}) </h2>
	<table>
			<tr>
				<td><b>Baslik</b></td>
				<td><b>Aciklama</b></td>
				<td><b>Kategori</b></td>
				<td><b>Herkes okuyabilir mi?</b></td>
				<td><b>Herkes degistirebilir mi?</b></td>
			</tr>
			{%for c in codes%}
				<tr>
					<td>{{c.title}}</td>
					<td>{{c.description}}</td>
					<td>{{c.category.name}}</td>
					<td>
						{% if c.readable %}
							<font style="background-color:#00cc00" color="#ffffff">Evet</font>
						{% else %}
							<font style="background-color:#cc0000" color="#ffffff">Hayir</font>
						{% endif %}
					</td>
					<td>
						{% if c.writable %}
							<font style="background-color:#00cc00" color="#ffffff">Evet</font>
						{% else %}
							<font style="background-color:#cc0000" color="#ffffff">Hayir</font>
						{% endif %}
					</td>					
				</tr>
			{%endfor%}
	</table>

{%endblock%}


